﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace JJYYCore.UIComponents.Slide
{
    public class SlideUIInRangeUpdater : MonoBehaviour
    {
        [SerializeField]
        private SlideUI slideUI;

        private bool isInside;
        private Vector2 screenPoint;

        private RectTransform targetRect;

        // Start is called before the first frame update
        void Start()
        {
            targetRect = transform.GetComponent<RectTransform>();
            slideUI.IsMouseInArea = false;
        }

        // Update is called once per frame
        void Update()
        {
            screenPoint = Input.mousePosition;
            isInside = RectTransformUtility.RectangleContainsScreenPoint(targetRect,screenPoint,null);
            slideUI.IsMouseInArea = isInside;
        }
    }
}